﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TomatoClock.Utils
{
    public class TimerConverter
    {
        private TimerConverter() { }

        static TimerConverter()
        {
            timerConverter = new TimerConverter();
        }
        private static TimerConverter timerConverter;

        public static TimerConverter Instance { get => timerConverter; }


        private int time;

        public int getMinutes()
        {
            long minutesTotal = (time / 1000 / 60);

            return (int)minutesTotal % 60;
        }

        public int getSeconds()
        {
            return (int)(time - (getHours() * 60 * 60 * 1000) - (getMinutes() * 60 * 1000)) / 1000;
        }

        public int getHours()
        {
            return (int)(time / 1000 / 60 / 60);
        }

        public string timeToString(int time)
        {
            this.time = time;
            return $"{getHours().ToString("D2")}:{getMinutes().ToString("D2")}:{getSeconds().ToString("D2")}";
        }
    }
}
